<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
	<script type="text/javascript">
		function dojobmakeemail(value, row, index) {
			var remove = "", reservedetail = "",forback="";
			var removeparam=row.emailId + ',"' + row.type + '"';
			var reservedetailparam=row.emailId + ',"' + row.type + '"';
			var thismakedname='"' + row.makedname + '"';
			reservedetail = "<a onclick='reservedetail("+reservedetailparam+")' class='easyui-linkbutton button-teal handle-btn'>邮件详情</a>";
			forback = "<a onclick='forbacktop("+ thismakedname +")' class='easyui-linkbutton button-blue handle-btn'>回复</a>";
			remove = "<a onclick='myreservedelete(" + removeparam + ")' class='easyui-linkbutton button-darkblue handle-btn'>删除</a>";
			return reservedetail +forback+ remove;
		}

		/* 收件箱删除 */
		function myreservedelete(emailId,type){
			if(type=="普通邮件"){
				$.post('myreservedeletege',{data:emailId},function(data){
					$.messager.alert('提示', '删除成功！', 'info'); 
					$("#makedemail-list").datagrid("load");
				});	
				
			}else{
				$.post('myreservedeleteco',{data:emailId},function(data){
					$.messager.alert('提示', '删除成功！', 'info'); 
					$("#makedemail-list").datagrid("load");
				});	
			}
			
		}
		
		/* 收件箱详情 */
		function reservedetail(emailId,type){
			if(type=="普通邮件"){
				$("#reservedetailinfo").datagrid({url: "myreservedetailgen?emailid=" + emailId+"&type='"+type+"'"});
				$("#reservedetailid").window("open");
			}else{
				$("#reservedetailinfo").datagrid({url: "myreservedetailcopy?emailid=" + emailId+"&type='"+type+"'"});
				$("#reservedetailid").window("open");
			}
			
		}
		
		/* 收件箱回复窗口 */
		function forbacktop(makedname){
			alert(makedname);
			$("#forbackname").html(makedname);
			$("#forbackwindow").window("open");
		}
		
		/* 回复已收件 */
		function forbackemail(){
			var forbackemailname=$("#forbackname").text();
			var forbackemailtheme=$("#forbacktheme").val();
			var forbackemailtext=$("#forbacktext").val();
			$.post('',{forbackemailname:forbackemailname,forbackemailtheme:forbackemailtheme,forbackemailtext:forbackemailtext},function(data){
				$.messager.alert('提示', '发送成功！', 'info'); 
				$("#forbackwindow").window('close');
			}); 
		}
	</script>
	<div class="easyui-layout" fit="true" >
		<!-- 已发送 -->
		<div id="makedemail" style="width:100%;height:100%;">
	        <table id="makedemail-list" class="easyui-datagrid" style="height:100%;width:100%;"
			data-options="
				url:'to_selectmyreserve',
				autoRowHeight:false,
				striped:true,
				pagination:true,
				rownumbers:true,
				singleSelect:true,
				fitColumns:true,
				remoteSort:false,
				pageList:[5,10]
			">   
        	<thead>   
	            <tr>
	            	<th data-options="field:'emailId',checkbox:true"></th> 
	            	<th style="width:8%;" align="center" data-options="field:'makedname'">发件人</th> 
	            	<th style="width:8%;" align="center" data-options="field:'name'">收件人</th>
	            	<th style="width:20%;" align="center" data-options="field:'startdate'">发件时间</th>
	            	<th style="width:30%;" align="center" data-options="field:'enddate'">收件状态</th>  
	            	<th style="width:10%;" align="center" data-options="field:'type'">发件类型</th>  	  
	            	<th style="width:24%;" align="center" data-options="field:'dojob',formatter:dojobmakeemail">操作</th>                 
	            </tr>   
       		</thead>   
    		</table>
		</div>
	</div>
	
	<!-- 收件详情窗口 -->
	<div id="reservedetailid" class="easyui-window" title="收件详情" data-options="collapsible:false,minimizable:false,maximizable:false,modal:true, closed: true" style="width:400px;height:310px;padding:5px;">
        <div class="easyui-layout" data-options="fit:true">
            <table id="reservedetailinfo" class="easyui-datagrid" style="height:100%;width:100%;"   
                data-options=" fitColumns:true,singleSelect:true,
                				autoRowHeight:true,singleSelect:true 
                " >   
                <thead>   
                    <tr style="border:1px solid white;height:100%;width:100%;">
                    	<th data-options="field:'name'" align="center"  style="width:20%;"></th>   
                        <th data-options="field:'value'" style="width:85%;"></th>                          
                    </tr>   
                </thead>   
            </table>
                 
            <div data-options="region:'south',border:false" style="text-align:right;padding:5px 0 0;">
                <a class="easyui-linkbutton" data-options="iconCls:'icon-cancel', plain:true" href="javascript:void(0)" onclick="$('#reservedetailid').window('close');">关闭</a>
            </div>
        </div>
    </div>
    
    <!-- 回复窗口 -->
    <div id="forbackwindow" class="easyui-window" title="回复邮件" data-options="collapsible:false,minimizable:false,maximizable:false,modal:true, closed: true" style="width:550px;height:400px;padding:5px;">
        <div class="easyui-layout" data-options="fit:true">
            <!-- 收件人 -->
            <div style="float:left;margin-top:5px;">
            	<div style="float:left;">收件人:&nbsp;</div><div id="forbackname" style="float:left;"></div>
            </div>
            <!-- 主题 -->
            <div style="clear:both;margin-top:30px;">
            	主&nbsp;&nbsp;题:&nbsp;<input id="forbacktheme" class="easyui-textbox" style="width:90%;border:1px solid #DADADA;">
            </div> 
            <!-- 内容  -->
            <div style="clear:both;margin-top:20px;">
            	<input id="forbacktext" class="easyui-textbox" label="内&nbsp;&nbsp;&nbsp;容:" multiline="true"
            	style="width:96%;height:95%;border:1px solid #DADADA;">
            </div> 
               
            <div data-options="region:'south',border:false" style="text-align:right;padding:5px 0 0;">
            	<a class="easyui-linkbutton" data-options="iconCls:'icon-ok', plain:true" href="javascript:void(0)" onclick="forbackemail()">发送</a>
                <a class="easyui-linkbutton" data-options="iconCls:'icon-cancel', plain:true" href="javascript:void(0)" onclick="$('#forbackwindow').window('close');">关闭</a>
                
            </div>
        </div>
    </div>
</body>
</html>